<template>
    <div class="role-agent">
        <!-- 编辑权限 -->
        <cvue-dialog :dialogVisible="dialogVisible"
            :dialogLoading="dialogLoading"
            title="权限"
            dialogWidth="550px"
            @handleOpen="getDetail"
            @closeDialog="closeDialog"
            @confirmDialog="confirmDialog"
            @handleClose="handleClose">
            <div class="dialog-body" slot="dialogBody">
                <el-form ref="dialog_rule" label-width="125px" class="demo-ruleForm" :model="agent">
                    <el-row>
                        <el-col :span="8">                
                            <el-checkbox v-model="agent.custNo" true-label='1' false-label='0' checked :label="agent.custNo">代理号</el-checkbox>                 
                        </el-col>
                        <el-col :span="8">
                            <el-checkbox v-model="agent.yhxm" true-label='1' false-label='0' checked :label="agent.yhxm">名称</el-checkbox>       
                        </el-col>
                        <el-col :span="8">
                            <el-checkbox v-model="agent.lxdh" true-label='1' false-label='0' checked :label="agent.lxdh">手机号</el-checkbox>       
                        </el-col>          
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-checkbox v-model="agent.sfzh" true-label='1' false-label='0' checked :label="agent.sfzh">身份证号</el-checkbox>      
                        </el-col>
                        <el-col :span="8">
                            <el-checkbox v-model="agent.csrq" true-label='1' false-label='0' checked :label="agent.csrq">出生年月</el-checkbox>      
                        </el-col>
                        <el-col :span="8">
                            <el-checkbox v-model="agent.xb" true-label='1' false-label='0' checked :label="agent.xb">性别</el-checkbox>      
                        </el-col>          
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-checkbox v-model="agent.jg" true-label='1' false-label='0' checked :label="agent.jg">籍贯</el-checkbox>     
                        </el-col>
                        <el-col :span="8">
                            <el-checkbox v-model="agent.dljbId" true-label='1' false-label='0' checked :label="agent.dljbId">代理级别</el-checkbox>    
                        </el-col>
                        <el-col :span="8">
                            <el-checkbox v-model="agent.yhzt" true-label='1' false-label='0' checked :label="agent.yhzt">用户状态</el-checkbox>    
                        </el-col>        
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-checkbox v-model="agent.tjrId" true-label='1' false-label='0' checked :label="agent.tjrId">推荐人</el-checkbox>  
                        </el-col>
                        <el-col :span="8">
                            <el-checkbox v-model="agent.tjrIdNew" true-label='1' false-label='0' checked :label="agent.tjrIdNew">新推荐人</el-checkbox>  
                        </el-col>
                        <el-col :span="8">
                            <el-checkbox v-model="agent.zcrq" true-label='1' false-label='0' checked :label="agent.zcrq">注册日期</el-checkbox>  
                        </el-col>          
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-checkbox v-model="agent.khhmc" true-label='1' false-label='0' checked :label="agent.khhmc">开户行名称</el-checkbox>  
                        </el-col>       
                        <el-col :span="8">
                            <el-checkbox v-model="agent.khm" true-label='1' false-label='0' checked :label="agent.khm">开户名</el-checkbox>  
                        </el-col>  
                        <el-col :span="8">
                            <el-checkbox v-model="agent.yhkh" true-label='1' false-label='0' checked :label="agent.yhkh">银行卡号</el-checkbox>  
                        </el-col>  
                    </el-row>
                    <el-row>  
                        <el-col :span="8">
                            <el-checkbox v-model="agent.shdz" true-label='1' false-label='0' checked :label="agent.shdz">收货地址</el-checkbox>  
                        </el-col> 
                        <el-col :span="8">
                            <el-checkbox v-model="agent.djr" true-label='1' false-label='0' checked :label="agent.djr">登记人</el-checkbox>  
                        </el-col> 
                        <el-col :span="8">
                            <el-checkbox v-model="agent.djsj" true-label='1' false-label='0' checked :label="agent.djsj">登记时间</el-checkbox>  
                        </el-col> 
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-checkbox v-model="agent.sfxnyh" true-label='1' false-label='0' checked :label="agent.sfxnyh">是否虚拟用户</el-checkbox>  
                        </el-col> 
                        <el-col :span="8">
                            <el-checkbox v-model="agent.sjtjr" true-label='1' false-label='0' checked :label="agent.sjtjr">实际用户</el-checkbox>  
                        </el-col> 
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-checkbox v-model="agent.bljsfjs" true-label='1' false-label='0' checked :label="agent.bljsfjs">伯乐奖是否结算</el-checkbox>  
                        </el-col> 
                        <el-col :span="8">
                            <el-checkbox v-model="agent.gxjsfjs" true-label='1' false-label='0' checked :label="agent.gxjsfjs">贡献奖是否结算</el-checkbox>  
                        </el-col> 
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-checkbox v-model="agent.tcje" true-label='1' false-label='0' checked :label="agent.tcje">套餐金额</el-checkbox>  
                        </el-col> 
                        <el-col :span="8">
                            <el-checkbox v-model="agent.djd" true-label='1' false-label='0' checked :label="agent.djd">第几代</el-checkbox>  
                        </el-col> 
                    </el-row>
                    </el-form>
            </div>
        </cvue-dialog>
    </div>
</template>
<script>
import cvueTreeGrid from '@/components/cvue-tree-grid'
import cvueDialog from '@/components/cvue-dialog'
import cvueTable from '@/components/cvue-table'
import {validPhone, validIp} from '@/util/validator.js'
export default {
    name: 'roleAgent',
    components: {
        cvueDialog,
        cvueTable,
        cvueTreeGrid
    },
    data () {
        return {
            ruleForm: {
                roleName: '',
                describe: ''
            },
            agent: {
                roleId: '',
                custNo: '',
                yhxm: '',
                xb: '',
                jg: '',
                csrq: '',
                sfzh: '',
                lxdh: '',
                dljbId: '',
                shdz: '',
                khhmc: '',
                khm: '',
                yhkh: '',
                tjrId: '',
                tjrIdNew: '',
                zcrq: '',
                djr: '',
                djsj: '',
                dljb: '',
                sfxnyh: '',
                sjtjr: '',
                bljsfjs: '',
                gxjsfjs: '',
                djd: '',
                tcje: '',
                yhzt: ''
            },
            disabled: true,
            dialogLoading: false
        }
    },
    props: {
        dialogVisible: {
            type: Boolean,
            default: false
        }
    },
    mounted () {
    },
    methods: {        
        // 触发事件
        handleClose () {
            // this.$refs['ruleForm'].resetFields()
            this.$emit('handleClose')
        },
        closeDialog () {
            // this.$refs['ruleForm'].resetFields()
            this.$emit('closeDialog')
        },
        confirmDialog () {
            this.agent.roleId = this.$parent.roleId
            this.$store.dispatch('system/SaveRoleEditor', this.agent).then((res) => {
                if (res.code === 200) {
                    this.dialogVisible = false
                    this.$emit('closeDialog')
                } else {
                    this.$message.error(res.msg)
                    // this.dialogVisible = false
                }
            })
        },
        // 初始化弹窗
        getDetail () {
            this.$store.dispatch('system/RoleEditorDetail', this.$parent.roleId).then((res) => {
                if (res.code === 200) {
                    if (res.data != null) {
                        this.agent = res.data
                    }                   
                } else {
                    this.$message.error(res.msg)
                    // this.dialogVisible = false
                }
            })
        }
    }
}
</script>
<style scoped lang="scss">
.role-agent{
    .dialog-body{
        height: 400px;
        overflow: auto;
    }
}
</style>
